//
//  BindCardSucceedViewController.m
//  PlayBall
//
//  Created by Edward Zhang on 12-5-8.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "JddBindCardSucceedViewController.h"

@interface JddBindCardSucceedViewController ()

@end

@implementation JddBindCardSucceedViewController

SHARED_VIEW_CONTROLLER_IMPLEMENT(JddBindCardSucceedViewController);
@synthesize bankName;
@synthesize bankCardId;
@synthesize bankCardUseName;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

  //  [self.navigationItem setTitle:PAGE_BIND_CARD];
        UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
        customLab.backgroundColor = [UIColor clearColor];
        [customLab setText:PAGE_BIND_CARD];
        customLab.textAlignment = NSTextAlignmentCenter;
        [customLab setTextColor:[UIColor whiteColor]];
        customLab.font = [UIFont systemFontOfSize:19];
        self.navigationItem.titleView = customLab;
        
        self.navigationItem.hidesBackButton = YES;
}

- (void)QueryUserInfoOperationResult:(NSData *)result{
    [JddCommonFunction setWaitingViewHidden:YES fromController:self];
    if (result) {
        if ([JddDataParser parseUserInfoResult:result]) {
            bankCardId.text = [JddUserProfile sharedInstance].BankCardNumber;
            bankName.text = [JddUserProfile sharedInstance].BankName;
            NSMutableString *realName =[[NSMutableString alloc] initWithString:[JddUserProfile sharedInstance].realName];
            if ([realName length] >= 2) {
                NSMutableString *str = [[NSMutableString alloc] init];
                for (int i=0; i<[realName length]-1; i++) {
                    [str appendString:@"*"];
                }
                [realName replaceCharactersInRange:NSMakeRange(1, [realName length]-1) withString:str];

            }
            bankCardUseName.text = realName;
        }
    }
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"BindCardSucceed"];
    [MobClick event:@"UserCenter-bindCardSucceed"];

    bankCardId.text = @"";
    bankName.text = @"";
    bankCardUseName.text = @"";
    JddQueryUserInfoOperation *operation1 = [[JddQueryUserInfoOperation alloc] init];
    operation1.delegate = self;
    [[JddGlobalParameter sharedInstance].operationQueue addOperation:operation1];
    
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"BindCardSucceed"];
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
